const util = require('./util.js')
// 使用 require 引入json文件，可以直接访问数据
const proxy = {
  'POST /categories/all': (req, res) => {
    res.send(util.getJsonFile('./categoryAll.json'))
  },
  'POST /tags/detail': (req, res) => {
    res.send(util.getJsonFile('./tagAll.json'))
  },
  'POST /archives': (req, res) => {
    res.send(util.getJsonFile('./archives.json'))
  },
  'POST /getArticles': (req, res) => {
    let pageNo = req.body.pageSize.pageNo
    let date = req.body.queryOptions.year + req.body.queryOptions.month
    let delayNumber = 2000
    if (date && date === '202007') {
      setTimeout(() => {
        res.send(util.getJsonFile(`./article${date}${pageNo}.json`))
      }, delayNumber)
    } else {
      setTimeout(() => {
        res.send(util.getJsonFile(`./article${pageNo}.json`))
      }, delayNumber)
    }
  },
  'POST /article/publish': {code: 0, data: {articleId: 0}}
}
module.exports = proxy
